// pages/tcm_dialectical/tcm_dialectical.js
Page({


  /**
   * 组件的初始数据
   */
  data: {
    nav_show:false,
    nav_title:'中医辩证',
    fontColor:'#333333',
    activeKey: 0,
    list:[
      {name:'脾胃消化',child:[{id:"0",name:"脾胃消化中医",wm:"0"},{id:"1",name:"脾胃消化西医",wm:"1"},{id:"2",name:"脾胃消化中医111",wm:"0"}]},
      {name:'肝胆系统',child:[{id:"0",name:"肝胆系统中医",wm:"0"},{id:"1",name:"肝胆系统西医",wm:"1"}]},
      {name:'心血管系统',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      {name:'肺呼吸系统2211',child:[{id:"0",name:"肺呼吸系统中医",wm:"0"},{id:"1",name:"肺呼吸系统西医",wm:"1"}]},
      {name:'心血管系统',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      {name:'心血管系统111',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      {name:'肺呼吸系统',child:[{id:"0",name:"肺呼吸系统中医",wm:"0"},{id:"1",name:"肺呼吸系统西医",wm:"1"}]},
      // {name:'儿科',child:[{id:"0",name:"儿科中医",wm:"0"},{id:"1",name:"儿科西医",wm:"1"}]},
      // {name:'脾胃消化',child:[{id:"0",name:"脾胃消化中医",wm:"0"},{id:"1",name:"脾胃消化西医",wm:"1"}]},
      // {name:'肝胆系统',child:[{id:"0",name:"肝胆系统中医",wm:"0"},{id:"1",name:"肝胆系统西医",wm:"1"}]},
      // {name:'心血管系统',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      // {name:'肺呼吸系统2211',child:[{id:"0",name:"肺呼吸系统中医",wm:"0"},{id:"1",name:"肺呼吸系统西医",wm:"1"}]},
      // {name:'心血管系统',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      // {name:'心血管系统111',child:[{id:"0",name:"心血管系统中医",wm:"0"},{id:"1",name:"心血管系统西医",wm:"1"}]},
      // {name:'肺呼吸系统',child:[{id:"0",name:"肺呼吸系统中医",wm:"0"},{id:"1",name:"肺呼吸系统西医",wm:"1"}]},
      // {name:'儿科',child:[{id:"0",name:"儿科中医",wm:"0"},{id:"1",name:"儿科西医",wm:"1"}]},
    ],
    list_detail_name:[],
    chineselist:[],
    westernlist:[],
  },
  onLoad(){
    // console.log(this.data.listdetail)
    // console.log(this.data.list[0].name)
    this.setData({
      list_detail_name:this.data.list[0].name
    })
    let index = 0
    this.changelistdetail(index)
  },

  /**
   * 组件的方法列表
   */
  sidebar(e){
    this.setData({
      list_detail_name:this.data.list[e.currentTarget.dataset.index].name
    })
    let index = e.currentTarget.dataset.index
    this.changelistdetail(index)
   
  },
  To_chinese_medicine(e){
    for (var i =0;i<this.data.chineselist.length;i++){
      if(e.currentTarget.id==this.data.chineselist[i].id){
          wx.navigateTo({
            url: '../medicine/medicine?name='+this.data.chineselist[i].name,
          })
      }
    }
  },
  To_western_medicine(e){
    for (var i =0;i<this.data.westernlist.length;i++){
      if(e.currentTarget.id==this.data.westernlist[i].id){
          wx.navigateTo({
            url: '../medicine/medicine?name='+this.data.westernlist[i].name,
          })
      }
    }
  },
  changelistdetail(index){
    let chineselist = []
    let westernlist = []
     for(var i=0 ;i<this.data.list[index].child.length;i++){
      // console.log(this.data.list[e.currentTarget.dataset.index].child[i].id)
      if(this.data.list[index].child[i].wm=="0"){
        chineselist.push(this.data.list[index].child[i])
        console.log(chineselist)
        this.setData({
          chineselist:chineselist
        })
      }
      else{
        westernlist.push(this.data.list[index].child[i])
        console.log(westernlist)
        this.setData({
          westernlist:westernlist
        })
      }
    }
  }
})
